package com.superme.uaaservice.configure;

import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.Ordered;
import org.springframework.web.filter.ForwardedHeaderFilter;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

/**
 * Created by Alex on 2017/5/24.
 */

@Configuration
public class LoginPageConfiguration extends WebMvcConfigurerAdapter
{
    @Bean
    FilterRegistrationBean forwardedHeaderFilter() {
        FilterRegistrationBean filterRegBean = new FilterRegistrationBean();
        filterRegBean.setFilter(new ForwardedHeaderFilter());
        filterRegBean.setOrder(Ordered.HIGHEST_PRECEDENCE);
        return filterRegBean;
    }

    @Override
    public void addViewControllers(ViewControllerRegistry registry) {
        //配合FREEMARK可以进行登录和授权页面的美化
        registry.addViewController("/login").setViewName("login");
        //可以通过注释取消自定义授权界面
        //registry.addViewController("/oauth/confirm_access").setViewName("authorize");
    }
}

